package ds.factcom.view.validate;

import ds.factcom.domain.client.DocumentType;
import ds.factcom.exception.EmptyStringException;
import ds.factcom.exception.IsNotNumberException;
import ds.factcom.exception.IsNotStringException;
import ds.factcom.exception.NotCorrectDocumentNumberException;
import ds.factcom.exception.NotCorrectDocumentTypeException;


/**
 * 
 * @author Javier De Luca, Maximiliano Herrera, Matias Samblancat
 *
 */
public class ValidatorClient extends Validator {

	public static void isCorrectDocumentType(String string) throws EmptyStringException, IsNotStringException, NotCorrectDocumentTypeException {
		isNotEmpty(string);
		isString(string);
		if (!(
			string.equalsIgnoreCase(DocumentType.CUIT.getValue())||
			string.equalsIgnoreCase(DocumentType.DU.getValue())||
			string.equalsIgnoreCase(DocumentType.DNI.getValue())
			)){
				throw new NotCorrectDocumentTypeException(string);
			}
	}
	
	public static void isCorrectDocumentNumber(String string) throws EmptyStringException, IsNotNumberException, NotCorrectDocumentNumberException{
		isNotEmpty(string);
		isNumber(string);
		if (!(isLargeMoreThan(Integer.valueOf(string)))){
			throw new NotCorrectDocumentNumberException(string);
		}
	}
	
	private static boolean isLargeMoreThan(Integer number){
		if(number  > 100000000){
			return false;
		}
		return true;
	}

	public static boolean isCorrectVip(String stringAux) throws EmptyStringException, IsNotStringException {
		isNotEmpty(stringAux);
		isString(stringAux);
		if("S".equalsIgnoreCase(stringAux)){
			return true;
		}else{
			return false;
		}
	}
}
